﻿#################################
# BASIC Tenliners Contest 2018  #
#                               #
# Golf64 with Course Selector   #
# (c) 2018 Roman Werner @romwer #
# email: roman.werner@gmail.com #
#################################

Golf64 with Course Selector is an add-on to Golf64 to make it easier to select a specific course.
It basically does nothing more than set up the «C=RND(-n)» for you that you otherwise would have to type in.


Task and Goal
=============
see Golf64


Control (Selection Screen):
===========================
press 1-9 on the keyboard to select the course
press <space bar> -or- fire button (Joystick port 1) to play course

see Golf64 for in-game control


Game Requirements:
==================
- C64/C128* with BASIC 2.0 runtime environment (or compatible)
- 1 Player

*Also playable on Windows/MacOS/iOS/Android (C64 Emulator required)


Starting in VICE: C64 emulator (http://vice-emu.sourceforge.net/):
==================================================================
Start the emulator and then drag and drop the "golf64cs.prg" into the VICE window.
-or-
Load the program with the command: load "golf64cs.prg",8
Then start the program with:       run


Golf64 with Course Selector BASIC program code:
===============================================
0m=53280:pOm,6:pOm+1,14:?"{light green}{clear}":e=0:h=h+1:c=c+p-q:q=0:z=20:k=z:j=197:ifl=0tHgO10
1a=int(rN(1)*25+20):g=int(rN(1)*60)+h*30:p=int(g/150)+3:v$="{home}{down}{down}{right}{right}{right}{right}    {left}{left}{left}{left}":f=0
2goS9:?:fOi=1to40:?"{reverse on}{light green} {down}{left} {down}{left} {up}{up}{reverse off}";:pOs+i,160:nE:pOo,190:ifh>9tHgO19
3?"{home}{down}{blue} ang"atA27)"hole"h"{left} "g"{left}m":?" pwr ?  "tA28)"par"p;q:?"{down} hcp"c:t=.1:wAj,60
4v=(v+1)aN127:?v$v;:on-(pE(j)<>64)gO4:q=q+1:?tA34)q:goS9:r=aB(a+180*f)*{pi}/180
5x=v*cos(r)*t:y=v*sI(r)*t-5*t^2-4.9*t^2:z=20-(y/2*aB(y>0)):e=d+x:f=e>g:w=190+f*2
6t=t+0.1:?tA20)"      {home}";:on-(z>=0)goS9:pO1944-k,160:ifn<19aNn>-22tHpO1885+n,160
7n=int(g-e):k=e+20-int((e+20)/40)*40:ifn<19aNn>-22tHpO1885+n,32:w=160:u=60
8pO1944-k,w:on-(y>0)gO5:v=0:d=e:on-(n<>-1)gO3:?" {down}{left}{white}Q":pOm,5:wAj,60:d=0:gO0
9pO214,z:pO211,20:sY58640:?"{white}Q{yellow}"int(e)"{left}m":?"{up}"tA20);:o=1924:s=1983:reT
10l=1
11a=rN(-l):?"{light green}{clear}{down}{blue}"tA12)"*** golf 64 ***":?tA12)"course selector"
12?tA15)"{down}course"l:?tA8)"{down}hole"tA14)"angle"tA21)"length"tA29)"par"
13?tA8)"===="tA14)"====="tA21)"======"tA29)"==="
14fOi=1to9:a=int(rN(1)*25+20):g=int(rN(1)*60)+i*30:p=int(g/150)+3:g$=stR(g)
15?tA8)i"{left}."tA14)atA21)rI(" "+g$,4)"m"tA29)p:nE:?"{down}{down}{light green}":a=rN(-l)
16fOi=1to40:?",{down}{left}{reverse on} {down}{left} {down}{left} {up}{up}{up}{reverse off}";:pO1983+i,160:nE
17?"{up}{up}"tA20)"{white}Q{down}{left}{light gray}t":?tA7)"{reverse on}{down}{light green}press 1-9 / space to start":h=0:c=0:p=0:pO198,0
18gEa$:on-(pE(j)=60)gO0:a=vA(a$):on-(a=0)gO18:l=a:gO11
19?"{home}{down}{down}{down}"tA12)"{blue}your handicap:"c:pO198,0:wAj,60:gO11

Tip: Copy/paste the program-Code into CBM prg Studio (http://www.ajordison.co.uk/).
There you can see the commands in nice color highlighting and you can directly execute the game in an emulator of your choice.


Variables used in the code (lines 10-19)
========================================
a  = angle (also used as temporary variable to call the rnd(-l) function)
a$ = key pressed (as string)
g  = distance from teeing green to hole
g$ = string of g value (to lign the number up nicely)
i  = only used in the for/next loop
j  = 197 (zeropage address containing the last pressed key - already assigned in line 0)
p  = par number
l  = selected course number

for lines 0-9 see Golf64
